package com.forlove.app.common.base.mvp.view;

import android.text.TextUtils;
import android.widget.Toast;

import com.forlove.app.ForloveApplication;
import com.forlove.app.manager.NetworkManager;
import com.forlove.app.qselect.CommonEntity;

/**
 * Created by yx on 2017/6/9.
 * 进行页面的操作
 */

public interface BaseView {
    public void showLoadingView();

    public void hideLoadingView();

    //跳转登录
    public void toLoginActivity();

    default void showErrorData(NetworkManager.ResultCode resultCode, String msg) {
        Toast.makeText(ForloveApplication.getInstance(), msg, Toast.LENGTH_SHORT).show();
    }

    default void showErrorData(String result) {
        CommonEntity commonEntity = new CommonEntity();
        commonEntity.parseJSONString(result);
        if (!TextUtils.isEmpty(commonEntity.message)) {
            showErrorData(NetworkManager.ResultCode.RESULT_FAIL, commonEntity.message);
        } else {
            showErrorData(NetworkManager.ResultCode.RESULT_ERROR, "稍后重试!");
        }
    }
}
